package com.gsta.ifishery.netty.client;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

/**
 * tcp客户端 . <br>
 * 
 * @author hkb
 */
public class TcpClient {

    public static void main(String[] args) throws IOException, InterruptedException {
        Socket socket = new Socket("localhost", 8088);
        OutputStream out = socket.getOutputStream();
        for (int i = 0; i < 2; i++) {
            // 第一次请求服务器
            String lines1 = "{\"name\":\"admin\",\"age\":20}\n";
            byte[] outputBytes1 = lines1.getBytes("UTF-8");
            out.write(outputBytes1);
            out.flush();

            // 第二次请求服务器
            String lines2 = "{\"name\":\"admin\",\"age\":21}\n";
            byte[] outputBytes2 = lines2.getBytes("UTF-8");
            out.write(outputBytes2);
            out.flush();
        }
        out.close();
        socket.close();
    }

}
